package com.itheima.Thraed.ThreadPrinciple;

public class demo5 {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() ->{
            System.out.println("sleep...");
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }, "t1");
        t1.start();
        Thread.sleep(2000);
        System.out.println("interrupt");
        // 打断线程
        t1.interrupt(); // 优雅的处理线程，让其有处理后事的机会，并不强制暂停
        System.out.println("打断标记: " +  t1.isInterrupted());
    }
}
